package com.cat.util;

import java.sql.*;

public class JdbcUtils {

    private static MyDataSource myDataSource =  MyDataSource.getInstance();

    private JdbcUtils() {

    }


    public static Connection getConnection()  {

        return myDataSource.getConnection();
    }

    public static void free(ResultSet rs, Statement st, Connection conn) {
        try {
            if (rs != null) {
                rs.close();
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        try {
            if (st != null) {
                st.close();
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        if (conn != null) {
            myDataSource.free(conn);
        }
    }


}
